#ifndef CRRTNODE_H
#define CRRTNODE_H

#include <ostream>
#include "CPoint.h"

class CRRTNode
{
public:
    CRRTNode()
    {
        m_point   = CPoint2D();
        m_parent  = nullptr;
        m_cost    = 0;
    }

    CRRTNode(const CPoint2D &point, CRRTNode *parent = nullptr)
    {
        m_point   = point;
        m_parent  = parent;
        m_cost    = 0;
    }

    CRRTNode(const CRRTNode &node)
    {
        this->m_point   = node.m_point;
        this->m_parent  = node.m_parent;
        this->m_cost    = node.m_cost;
    }

    ~CRRTNode() {   }

    void setPoint(const CPoint2D &point)      {     m_point = point;      }
    CPoint2D getPoint() const                 {     return m_point;       }

    void setParent(CRRTNode *parent)          {     m_parent = parent;    }
    CRRTNode *getParent() const               {     return m_parent;      }
    
    unsigned int getCost() const              {     return m_cost;        }

    friend std::ostream &operator << (std::ostream &os, const CRRTNode &node)
    {
        os << "point : [ " << node.getPoint().getX() << ", " << node.getPoint().getY() << " ]";
        return os;
    }

    bool operator == (const CRRTNode &node)
    {
        if (this->m_point   == node.m_point    \
         && this->m_parent  == node.m_parent)
        {
            return true;
        }

        return false;
    }

    CRRTNode &operator = (const CRRTNode &node)
    {
        this->m_point  = node.m_point;
        this->m_parent = node.m_parent;
        this->m_cost   = node.m_cost;

        return *this;
    }

private:
    CPoint2D  m_point;
    CRRTNode *m_parent;  
    unsigned int m_cost;
};


#endif // CRRTNODE_H
